/**
 * 编辑 课程通知记录详情对话框
 */
var NoticeLogInfoDlg = {
    data: {
		noticeLogId: "",
		courseId: "",
		userInfoId: "",
		wxType: "",
		templateId: "",
		msgId: "",
		createUser: "",
		createTime: ""
    }
};

layui.use(['layer', 'form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;

    // 让当前iframe弹层高度适应
    admin.iframeAuto();

    // 点击noticeLogName时 弹出树，不需要请删掉
    $('#noticeLogName').click(function () {
        var formName = encodeURIComponent("parent.NoticeLogInfoDlg.data.noticeLogName");
        var formId = encodeURIComponent("parent.NoticeLogInfoDlg.data.noticeLogId");
        var treeUrl = encodeURIComponent("/noticeLog/noticeLogTreeList");

        layer.open({
            type: 2,
            title: '父级 课程通知记录选择',
            area: ['300px', '200px'],
            content: Feng.ctxPath + '/system/commonTree?formName=' + formName + "&formId=" + formId + "&treeUrl=" + treeUrl,
            end: function () {
                $("#noticeLogId").val(NoticeLogInfoDlg.data.noticeLogId);
                $("#noticeLogName").val(NoticeLogInfoDlg.data.noticeLogName);
            }
        });
    });
	
	//获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/noticeLog/detail?noticeLogId=" + Feng.getUrlParam("noticeLogId"));
    var result = ajax.start();
    form.val('noticeLogForm', result.data);

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/noticeLog/edit", function (data) {
            Feng.success("添加成功！");
            //返回
			window.location.href = Feng.ctxPath + "/noticeLog?noticeLogId=" + $("#noticeLogId").val();
            /** 窗口返回前页模式
            //传给上个页面，刷新table用
            //admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();
            */
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
		return false;//返回
    });
	
	//返回按钮，需要同步修改页面按钮id
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + "/noticeLog?noticeLogId=" + $("#noticeLogId").val();
    });
});